function [y, s, n] = mean_nonan(arg)
% compute mean along columns of arg but only for data values not nan
% also compute std deviation of same data

if(iscell(arg))
    arg = reshape([arg{:}], [], length(arg));
end;
sz = size(arg);
y = zeros(sz(1),1);
s = y;
n = y;
for i = 1:sz(1) % along rows
    okpts = find(~isnan(arg(i,:)));
    y(i) = mean(arg(i,okpts));
    s(i) = std(arg(i,okpts));
    n(i) = length(okpts);
end;
return;
